package com.liziguo.lzgfp.system.util;

import java.util.Random;

/**
 * @Author: Liziguo
 * @Date: 2021/12/7 21:46
 */
public class RanStrUtil {

    public static String ranStr(final int len) {
        //为什么要写两次0-9 因为我想增加数字出现的几率
        final String c = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM01234567890123456789";
        final StringBuilder b = new StringBuilder();
        for (int i = 0; i < len; i++) {
            b.append(c.charAt(new Random().nextInt(c.length())));
        }
        return b.toString();
    }

    public static String ranNumber(final int len) {
        final String c = "0123456789";
        final StringBuilder b = new StringBuilder();
        for (int i = 0; i < len; i++) {
            b.append(c.charAt(new Random().nextInt(c.length())));
        }
        return b.toString();
    }

}
